package com.whty.web.controller.tool;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.whty.module.service.IUserService;
import com.whty.system.service.ITagService;
import com.whty.web.core.base.BaseController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * swagger 测试方法
 * 
 * @author ruoyi
 */
@Api("标签消息接收入口")
@RestController
@RequestMapping("/nfc/*")
public class MsgController extends BaseController
{
  
    private static Logger logger = LoggerFactory.getLogger(MsgController.class);
	@Autowired
	private ITagService tagService;
	
	@Autowired
	private IUserService userService;
	
    @ApiOperation("获取列表")
    @PostMapping("dna")
    public String praseMsg(@RequestBody String json)
    {
    	String resMsg="";
    	JSONObject msg=JSON.parseObject(json);
    	logger.info("app传入参数："+msg);
    	String txncode=msg.getString("txncode");
    	switch(txncode)
    	{
    	  case "TAGPUBLISH" : resMsg=tagService.tagPublish(msg); break;  //发布
    	  case "TAGAUTH"    :  resMsg=tagService.tagAuth(msg);  break;  //认证
    	  case "TAGUPDATE"  : resMsg=tagService.tagUpdate(msg);break;  //标签更新
    	  case "LOGIN"  :  resMsg=userService.userLogin(msg);break;    //登录
    	  case "PUBLISHRECORD"  :  resMsg=tagService.publishRecord(msg);break; //发布记录
    	  case "AUTHRECORD"  :  resMsg=tagService.authRecord(msg);break;  //认证记录
    	  case "TAGSTATUSQUERY"  :  resMsg=tagService.tagStatusQuery(msg);break; //标签状态查询
    	  case "SOURCEQUERY" : resMsg=tagService.sourceQuery(msg);break;  //溯源信息查询
    	}
    	logger.info("app返回数据："+resMsg);
        return resMsg;
    }

   

}
